<link rel="stylesheet" href="__CDN__/assets/libs/layui/css/layui.css" media="all">
<script type="text/javascript" src="__CDN__/assets/js/jquery-2.2.3.min.js"></script>
<script type="text/javascript" src="__CDN__/assets/libs/layui/layui.js"></script>
<table class="table table-striped">
    <thead>
    <tr>
        <th>{:__('Title')}</th>
        <th>{:__('Content')}</th>
    </tr>
    </thead>
    <tbody>
    {volist name="row" id="vo"}


    {if condition="in_array($key,['order_status','pay_status','type','address_id','deleted','first_user_id','shipping_status','item_id','order_prom_type','order_prom_id','user_prom_id'])"}

    {else/}
    <tr>
        <td>{:__($key)}</td>
        <td>{$vo}</td>
    </tr>
    {/if}

    {/volist}
    </tbody>
</table>

<fieldset class="layui-elem-field">
    <legend>收货人信息</legend>
    <div class="layui-field-box">
        <table class="table table-striped">

            <tbody>
            <tr><td>姓名</td><td>{$address.name}</td></tr>
            <tr><td>手机</td><td>{$address.mobile}</td></tr>
            <tr><td>地址</td><td>{$address.city}</td></tr>
            <tr><td>详细地址</td><td>{$address.address}</td></tr>

            </tbody>
        </table>

    </div>
</fieldset>



{if condition="$row.shipping_status eq 0"}

    {if condition="$row.type eq 0"}
        <!--自己买-->
        <!--<span>可发货</span>-->

    {else/}
        <!--送人-->
        {if condition="($row.type neq 0) and ($row.first_user_id gt 0)"}
            <!--收礼人提货-->
            <!--<span>可发货</span>-->

        {else/}
            <!--收礼人未提货-->
            <span>收礼人未提货</span>

        {/if}

    {/if}
{else/}
    <span>已发货</span>
{/if}
<fieldset class="layui-elem-field">
    <legend>发货设置</legend>
<form class="form-horizontal" role="form" data-toggle="validator" method="POST" action="" onsubmit="return false">

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Shipping_code')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-shipping_code" data-rule="required" class="form-control" name="row[shipping_code]" type="text" value="">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
        <div class="col-xs-12 col-sm-8">

            <select  id="c-shipping_name" data-rule="required" class="form-control selectpicker" name="row[shipping_name]">
                {foreach name="shippingList" item="vo"}
                <option value="{$vo}" >{$vo}</option>
                {/foreach}
            </select>

        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button  id="shipping_submit" class="btn btn-success btn-embossed ">{:__('确认发货')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>


</form>
</fieldset>





<script>
    function go_back() {
        history.go(-1);

    }

    //设置快递，物流单号
    $('#shipping_submit').click(function(){

        var order_id = "{$row.id}";
        var shipping_name = $('#c-shipping_name').val();
        var shipping_code = $('#c-shipping_code').val();

        console.log(shipping_name);
        console.log(shipping_code);

        $.ajax({
            type: 'get',
            url: "/admin/order/order/ajaxShippingOrder",
            data: {order_id:order_id,shipping_name:shipping_name,shipping_code:shipping_code},
            success: function(ret){
                if(ret.code == 1){
                    layer.msg(ret.msg, {
                        icon: 1,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function(){
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        window.parent.location.reload();
                    });

                }else{
                    layer.msg(ret.msg);
                }

            }
        });
    });


</script>